package practice.adil.encrypordecryp.JavaEncryptionOne;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * Created by 李园 - Adil on 2017/12/19.
 */
public class EncryptionSHA {
    public byte[] eccrypt(String info) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("SHA");
        byte[] srcBytes  =  info.getBytes();
        md5.update(srcBytes);
        // 完成哈希计算，得到result
        byte[] resultBytes  =  md5.digest();
        return  resultBytes;
    }

    public static void main(String[] args) throws NoSuchAlgorithmException {
        EncryptionSHA sha = new EncryptionSHA();
        String msg = "admin";
        byte[] resultByte = sha.eccrypt(msg);
        System.out.println("明文是"+msg);
        System.out.println("密文是"+ new String(resultByte));

    }
}

